@inherits ComputedStateComponent<TodoSummary>
@inject Session Session
@inject ITodos Todos
@inject ILogger<TodoSummaryBadge> Log

@{
    var summary = State.ValueOrDefault ?? TodoSummary.None;
    Log.LogInformation("Rendering: {Summary}", summary);
}

<Badge Color="Color.Success"><b>@summary.DoneCount</b> done</Badge>
<Badge Color="Color.Primary"><b>@summary.Count</b> total</Badge>

@code {
    protected override Task<TodoSummary> ComputeState(CancellationToken cancellationToken)
        => Todos.GetSummary(Session, cancellationToken);
}
